import tkinter as tk
import threading
from datetime import time


def long_running_task():
    # 模拟一个耗时的任务
    for i in range(5):
        print("Task running...")
        # time.sleep(1)
    print("Task completed!")

def start_thread():
    # 创建并启动线程
    thread = threading.Thread(target=long_running_task)
    thread.start()

if __name__ == '__main__':
    window = tk.Tk()

    # 创建按钮
    button = tk.Button(window, text="Start Thread", command=start_thread)
    button.pack()

    window.mainloop()